package com.zengjianjun.es.demo.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author zengjianjun
 */
public class RandomGenerator {

    public static String randomChinese(int length) {
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            // 生成一个随机的中文字符
            char chineseChar = (char) (random.nextInt(20902) + 19968);
            sb.append(chineseChar);
        }
        return sb.toString();
    }

    public static List<String> randomChineseList(int num, int length) {
        List<String> list = new ArrayList<>(num);
        for (int i = 0; i < num; i++) {
            list.add(randomChinese(length));
        }
        return list;
    }

    public static String randomCountry() {
        String[] countries = new String[]{
                "中国", "美国", "英国", "法国", "德国", "日本", "韩国", "印度", "巴西", "俄罗斯", "阿根廷", "迪拜", "刚果"
        };
        Random random = new Random();
        int randomIndex = random.nextInt(countries.length);
        return countries[randomIndex];
    }

    public static String random(List<String> list) {
        Random random = new Random();
        int randomIndex = random.nextInt(list.size());
        return list.get(randomIndex);
    }

}
